<template>
    <div class="component-exam">
        <div class="exam-wrap" v-for="item in list" :key="item.examId" @click="goTo(item)">
            <div class="item">
                <div class="item-title">
                    <span>{{ item.name }}</span>
                    <span class="f12">{{ item.examStatus | examState }}</span>
                </div>
                <p>开闭卷：{{ item.openBook ? "闭卷" : "开券" }}</p>
                <p>考试开始时间：{{ item.examStartTime | formatDateTime }}</p>
                <p>考试结束时间：{{ item.examEndTime | formatDateTime }}</p>
                <p>考试时限：{{ item.answerTimeLimit | formatMinute }}分钟</p>
                <p>成绩查询设置：{{ item.scoreOpen | scoreOpenState }}</p>
                <p>考试方式：{{ item.playback ? "可回看" : "不可回看" }}</p>
                <p>
                    答题顺序：{{
                    item.examQuestionSort == "UNSORT" ? "题型顺序不固定， 试题顺序随机" : "顺序"
                    }}
                </p>
                <p>是否需要改卷：{{ item.correction ? "是" : "否" }}</p>
                <p>改卷方式：常规阅卷</p>
                <!-- <p>卷面情况：A卷</p> -->
            </div>
        </div>
        <!-- <div class="wrap-footer">查看更多 ></div> -->
    </div>
</template>
<script>
// import { throttle } from "filters/throttle.js";
import { mapState } from "vuex";
export default {
    name: "notice",
    props: {
        list: {
            type: Array,
            default: [],
        },
    },
    computed: {
        ...mapState({
            examId: state => state.exam.examId,
        }),
    },
    data() {
        return {};
    },
    methods: {
        goTo(data) {
            
            if (new Date(data.examEndTime).getTime() - new Date().getTime() > 0) {
                if (data.examId === this.examId) {
                    this.$router.push({
                        path: "/exam",
                        query: {
                            examId: data.examId,
                            time: data.answerTimeLimit,
                        },
                    });
                } else {
                    this.$store.commit("exam/CLEAR_EXAM");
                    this.$store.commit("exam/SET_examInfo", data);
                    this.$router.push({
                        path: "/exam-instruction",
                        query: {
                            examCode: data.examCode,
                            examId: data.examId,
                            examStartTime: new Date(data.examStartTime).getTime(),
                            answerTime: data.answerTimeLimit,
                        },
                    });
                }
            } else {
                this.$toast.fail("考试已结束");
            }
        },
    },
};
</script>
<style scoped lang="scss">
.component-exam {
    background-color: #21202e;
    padding: 15px;
    .title {
        color: #fff;
        font-size: 18px;
        margin-bottom: 10px;
    }
    .item {
        padding: 15px;
    }
    .item-title {
        font-size: 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
    }
    .wrap-footer {
        padding: 15px 10px;
        text-align: right;
        font-size: 12px;
    }
    .exam-wrap {
        border: 1px solid #2d2c3c;
        margin-bottom: 10px;
    }
    p {
        line-height: 26px;
        font-size: 12px;
    }
}
</style>
